package com.icoopoo.modules.evn.web;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.icoopoo.utils.properties.PropertiesHelper;
import com.icoopoo.utils.properties.PropertyUtil;
import com.icoopoo.utils.resultResponse.HelperResponse;


/**
 * 
 * @描述:读取properties 文件
 * @作成者:leihao 
 * @Data:2018年12月5日 下午3:57:05
*
 */
@Controller
@RequestMapping("properties")
public class PropertiesController {
	
	
	@ResponseBody
	@RequestMapping(value = "/propertiesUtil",method = RequestMethod.GET)
	public Map<String, Object> propertiesUtil(HttpServletRequest request, HttpServletResponse response) {
		try{
			
			System.out.println(PropertyUtil.getProperty("test.param.evnUserNameSpringMvc"));
			
		}catch(Exception e){
			return HelperResponse.errorMap(null);
		}
		return HelperResponse.successMap(null);
	}
	
	@ResponseBody
	@RequestMapping(value = "/propertiesHelper",method = RequestMethod.GET)
	public Map<String, Object> propertiesHelper(HttpServletRequest request, HttpServletResponse response) {
		try{
			String rootUrl = request.getSession().getServletContext().getRealPath("/");
			System.out.println(rootUrl);
			PropertiesHelper ph = new PropertiesHelper(rootUrl+"config\\modules\\common.properties");
			System.out.println("test.param.evnUserNameSpringMvc : "+ph.getString("test.param.evnUserNameSpringMvc"));
			
		}catch(Exception e){
			return HelperResponse.errorMap(null);
		}
		return HelperResponse.successMap(null);
	}
}
